import React, {useEffect, useState} from "react";
import CommentView from "../CommentView";
import api from "../../../api";

const Comment=(props)=> {
    const [comment, setcomment] = useState([])
    useEffect(() => {
        api.comment({id: props.id}).then(res => {
            if (res.data.status === 200) {
                setcomment(res.data.result.data)
                console.log(comment)
            }
        }).catch(error => {
            console.log(error)
        })

    }, [])


    return (
        <div>
            {
                comment.length > 0 ?
                    <CommentView data={comment}/> :
                    <div>等待你评论哦......</div>
            }
        </div>

    )
}
export default Comment